home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 32 / cadence.zip / VOL2NO3.ZIP / KRAM387.LSP < prev    next >
Text File  |  1987-05-14  |  3KB  |  52 lines

  1. ======================================================================================================
  2. ;
  3. ; Input/Output Expresion Examples.
  4. ;
  5. ; Listing 1: Long distance calculation
  6. ; Bill Kramer
  7. ;
  8. (defun c:long-dist ()
  9.    (setq Tot-dist 0.0 Cnt 0 Exit nil)                             ; Initialize
  10.    (setq P1 (getpoint "\nStarting point:"))                       ; First point entry
  11.    (while (null Exit)
  12.      (setq P2 (getpoint "\nNext point:"))                         ; Next point entry
  13.      (cond
  14.        ((null P2)(setq Exit 1))                                   ; Nothing entered, set exit.
  15.        (t (prompt "Distance: ")                                   ; Display distance during calc.
  16.           (setq Tot-dist (+ Tot-dist (princ (distance P1 P2)))
  17.                 Cnt (1+ Cnt)                                      ; Increment leg counter.         
  18.                 P1 P2))))
  19.     (prompt "\nTotal traversed distance: ")
  20.     (princ Tot-dist)                                              ; Report total distance traveled.
  21.     (prompt "  Ave: ")
  22.     (if (> Cnt 0)(princ (/ Tot-dist Cnt))(prompt "0"))            ; Ave only if CNT > 0
  23.     (prompt "\nLong distance measurement complete..."))
  24.  
  25.  
  26. ;
  27. ==============================================================================================================
  28. ;
  29. ; Listing 2. Data Typist
  30. ; Bill Kramer
  31. ;
  32. (defun C:data-type ()
  33.    (setvar "CMDECHO" 0)                                           ; Turn off AutoCAD command echo.
  34.    (setq P1 (getpoint "\nStart point of text (left justify): "))
  35.    (setq TH (getdist P1 "\nText height: "))
  36.    (if (null TH)(setq TH (getvar "TEXTSIZE")))                    ; If nothing entered, use default
  37.    (setq TR (getangle P1 "\nRotation angle: "))
  38.    (if (null TR)(setq TR 0.0))                                    ; If nothing entered, use 0.0
  39.    (setq VT (getdist P1 "\nVertical distance: ")) 
  40.    (if (null VT)(setq Exit 1)(setq Exit nil))                     ; If nothing entered, exit
  41.    (while (null Exit)
  42.      (prompt "\nEnter: ")                                         ; Prompt for user entry of text line.
  43.      (setq Txt (read-line))                                       ; Read line of text.
  44.      (cond
  45.        ((= Txt " ")(setq Exit 1))                                 ; Null text line, set exit condition
  46.        (t
  47.          (command "TEXT" P1 TH TR Txt)                            ; Output text information on display
  48.          (setq P1 (polar P1 (* 1.5 PI) VT))))                     ; Calc next line of text position
  49.      )
  50.      (prompt "\nData entry ends.")                                ; Prompt end of program.
  51. )        
  52.